	AREA Example1,CODE,READONLY
	CODE32
		
	EXPORT sort
	
sort
	;PUSH register
	MOV SP,#0X320000
	STMFD R13!,{R0-R12}
	

					;R1 len
	SUB R4,R1,#0X1  ;R4 len-1
	
	MOV R3,#0X0		;R3 i
	MOV R5,#0X0		;R5 j
					;R6 len-1-i
					;[R9] addr
	B LOOP1	
SWAP
	STR R7,[R9]
	STR R8,[R9,#-4]
	B CONTINUE	
LOOP1
	MOV R9,R0
	MOV R5,#0X0		;j=0
LOOP2
	LDR R7,[R9],#4
	LDR R8,[R9]
	CMP R7,R8
	BGE SWAP	
CONTINUE
	SUB R6,R4,R3
	ADD R5,R5,#0X1
	CMP R6,R5
	BNE LOOP2

	ADD R3,R3,#0X1	
	CMP R4,R3		
	BNE LOOP1
	
	;POP register	
	LDMFD R13!,{R0-R12}
	
	MOV PC,LR	
	END